package io.renren.modules.generator.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.generator.entity.棚圈环境Entity;
import io.renren.modules.generator.service.棚圈环境Service;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;




/**
 * 棚圈环境
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-05-01 21:59:01
 */
@RestController
@RequestMapping("棚圈环境")
public class 棚圈环境Controller {
	@Autowired
	private 棚圈环境Service 棚圈环境Service;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("棚圈环境:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<棚圈环境Entity> 棚圈环境List = 棚圈环境Service.queryList(query);
		int total = 棚圈环境Service.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(棚圈环境List, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id1}")
	@RequiresPermissions("棚圈环境:info")
	public R info(@PathVariable("id1") Long id1){
		棚圈环境Entity 棚圈环境 = 棚圈环境Service.queryObject(id1);
		
		return R.ok().put("棚圈环境", 棚圈环境);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("棚圈环境:save")
	public R save(@RequestBody 棚圈环境Entity 棚圈环境){
		棚圈环境Service.save(棚圈环境);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("棚圈环境:update")
	public R update(@RequestBody 棚圈环境Entity 棚圈环境){
		棚圈环境Service.update(棚圈环境);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("棚圈环境:delete")
	public R delete(@RequestBody Long[] id1s){
		棚圈环境Service.deleteBatch(id1s);
		
		return R.ok();
	}
	
}
